
const http = require('http')
class Koa {
  constructor() { }
  middleware = () => { };
  listen(port, cb) {
    const server = http.createServer((req, res) => {
      this.middleware(req, res);
    });
    return server.listen(port, cb);
  }
  use(middlewareFn) {
    this.middleware = middlewareFn;
    return this;
  }
}

const app = new Koa();

app.use((ctx,res) => {
  res.end("Hello World");
});

app.listen(3000);